<template>
  <div class="page-films">
    <div class="page-films__header">
      <van-tabs v-model:active="activeRoute" @change="onChange">
        <van-tab name="/films/now-playing" title="正在热映"></van-tab>
        <van-tab name="/films/coming-soon" title="即将上映"></van-tab>
      </van-tabs>
    </div>
    <div class="page-films__body">
      <router-view />
    </div>
  </div>
</template>

<script>
export default { name: "films" };
</script>

<script setup>
import { ref } from "vue";
import { useRouter, useRoute } from "vue-router";

const router = useRouter();
const route = useRoute();

const activeRoute = ref(route.path);
function onChange(data) {
  console.log("onChange", data);
  // 编程式导航
  router.replace(data);
}
</script>

<style lang="scss" scoped>
.page-films {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  &__header {
    height: 50px;
  }
  &__body {
    flex: 1;
    overflow-y: auto;
  }
}
</style>
